package fenixnax.hello.hangman;

import fenixnax.hello.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class HangmanView extends SurfaceView{
	
	private int canvasWidth;
	private int canvasHeight;
	private Bitmap mSnowflake;
	
	public HangmanView(Context context, AttributeSet attrs) {
		super(context,attrs);
		System.out.println("##View STARTING");
		mSnowflake = BitmapFactory.decodeResource(context.getResources(), R.drawable.snowflake);
	}
	

    public void setSurfaceSize(int width, int height) {
        synchronized (getHolder()) {
            canvasWidth = width;
            canvasHeight = height;
        }
    }
    
    public void drawCanvas() {
    	
    	System.out.println("##View PAINTING");
    	
    	Canvas canvas = getHolder().lockCanvas(null);
    	
    	synchronized (getHolder()) {
    		canvas.drawARGB(255, 0, 0, 0); //empty canvas
    		canvas.drawBitmap(mSnowflake, 5, 5, new Paint());
    	}
    }

}
